package br.com.tonaaula;

import android.os.Bundle;
import android.preference.PreferenceManager;
import android.app.Activity;
import android.content.SharedPreferences;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;

public class AddDisciplinaActivity extends Activity {

	private EditText texto;
	
	private DatabaseHelper helper;

	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_add_disciplina);
		texto = (EditText) findViewById(R.id.editText1);
		
		SharedPreferences pref = PreferenceManager.
				getDefaultSharedPreferences(this);

		//SharedPreferences pref = getPreferences(MODE_PRIVATE);
		String value = pref.getString("curso","padrao");
		texto.setText(value);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.add_disciplina, menu);
		return true;
	}
	
	
	public void adicionar(View v){
		//MainActivity.disciplinas.add(texto.getText().toString());
		helper = new DatabaseHelper(this);
		DisciplinaDAO dao = new DisciplinaDAO(helper);
		dao.salvar(texto.getText().toString());
		finish();
	}

}
